<!-- Phan khai bao bien cuc bo-->
<?php
$v_filter = "";
if(isset($_REQUEST['hdn_filter'])){
	$v_filter= _replace_bad_char(trim($_REQUEST['hdn_filter']));
}	
$v_current_style_name = "odd_row";
$v_next_style_name = "round_row";
$v_count = count ($arr_all_agency);
// Luu ten form
$v_form_name = "f_dsp_all_agency";
$v_goto_url = "list/agency/index.php";
$v_current_item_id = '';
if (isset($_REQUEST['hdn_item_id'])){
	$v_current_item_id = $_REQUEST['hdn_item_id'];
}
?>
<!--bang chua tieu de cua form-->
<table width="100%" cellpadding="0" cellspacing="0">
	<tr class="normal_title">
		<td><?php echo CONST_LIST_AGENCY;?><a id="goto" href="" style=".color:white">#</a></td>
	</tr>
</table>
<!-- bang chua cac tieu thuc loc-->
<table cellpadding="0" cellspacing="0" width="99%">
	<form action="index.php" name="<?php echo $v_form_name; ?>" method="post">
	<input name="hdn_agency_id" type="hidden" value="">
	<input name="hdn_item_id" type="hidden" value="">
	<input name="hdn_list_agency_id" type="hidden" value="0">
	<input name="fuseaction" type="hidden" value="">
	<input name="hdn_max_order" type="hidden" value="0">
	<input name="hdn_filter" type="hidden" value="<?php echo $v_filter; ?>">
	<tr>
		<td class="normal_label" align="right"><?php echo CONST_AGENCY_LIST_FILTER_LABEL;?>
				<input type="text" class="normal_textbox" size="15" name="txt_filter_value" value="<?php echo $v_filter; ?>" onKeyDown="txt_filter_keydown()">
				<input type="button" class="small_button" name="btn_filter" value="<?php echo _CONST_FILTER_BUTTON; ?>" onClick="btn_filter_onclick(document.forms(0).hdn_filter,document.forms(0).txt_filter_value,'DISPLAY_ALL_AGENCY')">
		</td>
	</tr>	
</table>
<!-- Bat cac phim: F12=false; Insert=true; Delete=true, ESC=false; Enter=false -->
<div id="hotkey" onKeyDown="javascript:process_hot_key(false,true,true,false,false);">
<!--Bang noi dung chua danh sach cac loai hinh xay dung-->
<table class="list_table2" width="100%" cellpadding="0" cellspacing="0">
	<col width="5%"><col width="60%"><col width="20%"><col width="15%">
	<tr class="header">
		<td>#</td>
		<td><?php echo CONST_AGENCY_NAME_LABEL; ?></td>
		<td align="center"><?php echo CONST_AGENCY_ORDER_LABEL; ?></td>
		<td align="center"><?php echo _CONST_STATUS_COLUMN_HEADER; ?></td>
	</tr>
</table>	
<div style="overflow: auto; width: 100%; height:<?php echo _CONST_HEIGHT_OF_LIST;?>;padding-left:0px;margin:0px">
<table class="list_table2" width="100%" cellpadding="0" cellspacing="0">
	<col width="5%"><col width="60%"><col width="20%"><col width="15%">
	<?php  
	$v_agency_order = 0;
	if ($v_count>0){
		for($row_index = 0;$row_index< $v_count;$row_index++){
			$v_agency_id = $arr_all_agency[$row_index]['0'];
			$v_agency_code = _replace_bad_char($arr_all_agency[$row_index]['1']);
			$v_agency_name = _replace_bad_char($arr_all_agency[$row_index]['2']);
			$v_agency_order = $arr_all_agency[$row_index]['3'];
			$v_agency_status = $arr_all_agency[$row_index]['4'];
			if ($v_agency_status==1){$v_agency_status=_CONST_STATUS_COLUMN_ACTIVE_VALUE;}else{$v_agency_status=_CONST_STATUS_COLUMN_INACTIVE_VALUE;}
			$v_url = "row_onclick(" . "document.forms(0).hdn_agency_id"  . "," . $v_agency_id . "," . "'DISPLAY_SINGLE_AGENCY','" . $v_goto_url . "')";
			if ($v_current_style_name == "odd_row"){
				$v_current_style_name = "round_row";
			}else{
				$v_current_style_name = "odd_row";
			}?>	
			<tr class="<?php echo $v_current_style_name ?>"> 
				<td class="center">
					<input type="checkbox" name="chk_agency_id" value="<?php echo $v_agency_id; ?>">
				</td>	
				
				<td  align="left" onclick="<?php echo $v_url ;?>">
					<a name="<?php echo $v_agency_id;?>"><?php echo $v_agency_name; ?>&nbsp;</a>
				</td>
				<td  align="center" onclick="<?php echo $v_url ;?>" class="normal_label">
					<a name="<?php echo $v_agency_id;?>"><?php echo $v_agency_order; ?>&nbsp;</a>
				</td>
				<td align="center" onclick="<?php echo $v_url ;?>" class="normal_label">
					<a name="<?php echo $v_agency_id;?>"><?php echo $v_agency_status; ?>&nbsp;</a>
				</td>
			</tr><?php 
		}	
	}
	if ($v_current_style_name == "odd_row"){
		$v_next_style_name = "round_row";
	}else{
		$v_next_style_name = "odd_row";
	}
	echo _add_empty_row($v_count,_CONST_NUMBER_OF_ROW_PER_LIST,$v_current_style_name,$v_next_style_name,4);
	?>
</table>
</div>
<!--Table chua cac button-->
<table align="center">
	<tr><td height="10"></td></tr>
	<tr>
		<td><?php
			if ($v_is_granted_update){?>
				<input type="button" value="<?php echo _CONST_ADD_BUTTON; ?>" name="btn_add" class="normal_button" onClick="btn_add_onclick(document.forms(0).hdn_agency_id, 'DISPLAY_SINGLE_AGENCY','<?php echo $v_goto_url; ?>')"><?php
			}	
			if ($v_is_granted_update){?>
				<input type="button" value="<?php echo _CONST_DELETE_BUTTON; ?>" name="btn_delete" class="normal_button" onClick="btn_delete_onclick(document.forms(0).chk_agency_id,document.forms(0).hdn_list_agency_id,'DELETE_AGENCY')"><?php
			}?>	
		</td>
	</tr>
</table>
</div id="hotkey">
</form>
<Script>
	document.all.goto.href="#<? echo $v_current_item_id;?>";
	document.all.goto.click();
	document.forms(0).hdn_max_order.value =<?php echo $v_agency_order;?>;
</Script>

